pub fn odd_fibnacci_sum(threshold: u32) -> u32 {
    if threshold == 2 {
        return 2;
    } else if threshold < 2{
        return 0;
    }
    let mut a = 0;
    let mut b = 1;
    let mut n = 2;
    while b < threshold {
        a = a + b;
        b = b + a;
        n += 2;
    }
    // println!("{},{}", a, b);
    if a >= threshold && a % 2 == 0 {
        // println!("1");
        if n % 3 == 2 {
            (a + b - 1) / 2
        } else {
            (b + b - a - 1) / 2
        }
    } else if a >= threshold && a % 2 == 1 && b % 2 == 0 {
        // println!("2");
        if n % 3 == 2 {
            (a + b - 1) / 2
        } else {
            (b + b - a - 1) / 2
        }
    } else if a >= threshold && a % 2 == 1 && b % 2 == 1 {
        // println!("3");
        if n % 3 == 0 {
            (b - 1) / 2
        } else {
            (3 * a - b - 1) / 2
        }
    } else if b > threshold && b % 2 == 0 {
        // println!("4");
        if n % 3 == 1 {
            (a + b + b - 1) / 2
        } else {
            (a + a + b - 1) / 2
        }
    } else if b > threshold && b % 2 == 1 && a % 2 == 0 {
        // println!("5");
        if n % 3 == 2 {
            (a + b - 1) / 2
        } else {
            (b + b - a - 1) / 2
        }
    } else if b > threshold && b % 2 == 1 && a % 2 == 1 {
        // println!("6");
        if n % 3 == 1 {
            (a + b + b - 1) / 2
        } else {
            (a + a + b - 1) / 2
        }
    } else {
        unreachable!()
    }
}
